package Acwing.数学知识;

import java.util.Scanner;

/**
 * @Title: decomposePrimeFactors
 * @Author 贾金博
 * @Package Acwing.数学知识
 * @Date 2025/4/10 下午10:29
 * @description: 分解质因数
 */
public class decomposePrimeFactors {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        while(n -- > 0 ) {
            int x = sc.nextInt();

            // 开始对 x 进行分解质因数
            for(int i = 2; i <= x; i ++ ) {
                int count = 0;
                while(x % i == 0 ) {
                    x /= i;
                    count ++ ;
                }
                if(count != 0) {
                    System.out.println(i + " " + count);
                }
            }
            if(x > 1) {
                System.out.println(x + " " + 1);
            }
            System.out.println("");
        }
    }
}
